-- liquibase formatted sql

-- changeset karmanchikova-ev:2905

create table post
(
    id   bigserial primary key,
    name text not null
);

create table employee
(
    id        bigserial primary key,
    full_name text not null,
    gender    text not null
        check ( gender in ('M', 'F')),
    login     text not null,
    post_id   bigint
        references post
);

create table client
(
    id        bigserial primary key,
    full_name text not null,
    gender    text not null
        check ( gender in ('M', 'F')),
    dob       timestamp,
    inn       text not null,
    snils     text not null,
    phone     text not null
);

create table tur_order
(
    id          bigserial primary key,
    date        timestamp,
    employee_id bigint
        references employee,
    client_id   bigint
        references client,
    price       text not null

);

create table city
(
    id   bigserial primary key,
    name text not null
);

create table order_city
(
    id              bigserial primary key,
    city_id         bigint
        references city,
    tur_order_id        bigint
        references tur_order,
    date_start      timestamp,
    date_expiration timestamp
);
